<?php

namespace app\forms\user;

use app\forms\Model;
use app\models\User;
use app\components\validators\PositiveInteger;

class DeleteForm extends Model
{
    public $id;

    public function rules()
    {
        return [
            ['id', 'required'],
            ['id', PositiveInteger::class],
            ['id', 'exist', 'targetClass' => User::class]
        ];
    }

    public function deleteUser()
    {
        $u['is_deleted'] = 1;
        $u['deleted_at'] = $u['updated_at'] = $_SERVER['REQUEST_TIME'];
        User::updateByPk($u, $this->id);
    }
}